<?php

class Ht_Plugin_Rightcol extends Zend_Controller_Plugin_Abstract
{
	
	protected function _renderRightcol(Zend_Controller_Request_Abstract $request)
	{
		$rightcol = "";
		
		$p = new Model_Project();
		$projects = $p->getAll()->toArray();
		
		if($request->getControllerName() == "tickets") {
			$rightcol .= '<select id="select_filtertickets">';
			$rightcol .= '<option value="">wählen Sie ein Projekt...</option>';
			$rightcol .= '<option value="/'.Zend_Registry::get('Zend_Locale').'/tickets/">alle Projekte</option>';
			foreach($projects as $project) {
				$rightcol .= '<option value="/'.Zend_Registry::get('Zend_Locale').'/tickets/filterbyproject/pid/'.$project['pid'].'">'.$project['ptitle'].'</option>';
			}
			$rightcol .= '</select>';
		}
		
		return $rightcol;
	}
	
	public function postDispatch(Zend_Controller_Request_Abstract $request)
	{
		Zend_Layout::getMvcInstance()->rightcol = $this->_renderRightcol($request);
	}
};
?>